package com.iknow.db;

import android.database.Cursor;
import android.provider.BaseColumns;
import com.iknow.xmpp.service.AudioMessage;
import com.iknow.xmpp.service.ImageMessage;
import com.iknow.xmpp.service.Message;
import java.util.Date;

public class MessageTable
  implements BaseColumns
{
  public static final String BODY = "body";
  public static final String CREATE_TABLE = "create table XmppMessage (thread text not null, type text not null, iknowType integer, body text not null, subject text, msgto text not null, msgfrom text not null, msgtime text not null,loc_time text not null,isRead integer,status integer,source text)";
  public static final String FROM = "msgfrom";
  public static final String IKNOW_MESSAGE_TYPE = "iknowType";
  public static final String IS_READ = "isRead";
  public static final String LOCAL_TIME = "loc_time";
  public static final String MESSAGE_ID = "thread";
  public static final String SOURCE = "source";
  public static final String STATUS = "status";
  public static final String SUBJECT = "subject";
  public static final String[] TABLE_COLUMNS;
  public static final String TABLE_NAME = "XmppMessage";
  public static final String TAG = "MessageTable";
  public static final String TIME = "msgtime";
  public static final String TO = "msgto";
  public static final String TYPE = "type";

  static
  {
    String[] arrayOfString = new String[12];
    arrayOfString[0] = "thread";
    arrayOfString[1] = "type";
    arrayOfString[2] = "iknowType";
    arrayOfString[3] = "body";
    arrayOfString[4] = "subject";
    arrayOfString[5] = "msgto";
    arrayOfString[6] = "msgfrom";
    arrayOfString[7] = "msgtime";
    arrayOfString[8] = "loc_time";
    arrayOfString[9] = "isRead";
    arrayOfString[10] = "status";
    arrayOfString[11] = "source";
    TABLE_COLUMNS = arrayOfString;
  }

  public static Message parseMessage(Cursor paramCursor)
  {
    Object localObject;
    if ((paramCursor == null) || (paramCursor.getCount() == 0))
      localObject = null;
    while (true)
    {
      int i;
      while (true)
      {
        while (true)
        {
          return localObject;
          i = paramCursor.getInt(paramCursor.getColumnIndex("iknowType"));
          switch (i)
          {
          default:
            localObject = null;
          case 16:
          case 17:
          case 18:
          }
        }
        Message localMessage = new Message(paramCursor.getString(paramCursor.getColumnIndex("msgto")), paramCursor.getInt(paramCursor.getColumnIndex("type")));
        localMessage.setFrom(paramCursor.getString(paramCursor.getColumnIndex("msgfrom")));
        localMessage.setSubject(paramCursor.getString(paramCursor.getColumnIndex("subject")));
        localMessage.setBody(paramCursor.getString(paramCursor.getColumnIndex("body")));
        localMessage.setiKnowMsgType(i);
        localMessage.setTimestamp(new Date(paramCursor.getLong(paramCursor.getColumnIndex("msgtime"))));
        localObject = localMessage;
      }
      ImageMessage localImageMessage = new ImageMessage(paramCursor.getString(paramCursor.getColumnIndex("msgto")), paramCursor.getInt(paramCursor.getColumnIndex("type")));
      localImageMessage.setFrom(paramCursor.getString(paramCursor.getColumnIndex("msgfrom")));
      localImageMessage.setFileName(paramCursor.getString(paramCursor.getColumnIndex("source")));
      localImageMessage.setBody(paramCursor.getString(paramCursor.getColumnIndex("body")));
      localImageMessage.setTimestamp(new Date(paramCursor.getLong(paramCursor.getColumnIndex("msgtime"))));
      localImageMessage.setiKnowMsgType(i);
      AudioMessage localAudioMessage = new AudioMessage(paramCursor.getString(paramCursor.getColumnIndex("msgto")), paramCursor.getInt(paramCursor.getColumnIndex("type")));
      localAudioMessage.setFrom(paramCursor.getString(paramCursor.getColumnIndex("msgfrom")));
      localAudioMessage.setFileName(paramCursor.getString(paramCursor.getColumnIndex("source")));
      localAudioMessage.setBody(paramCursor.getString(paramCursor.getColumnIndex("body")));
      localAudioMessage.setTimestamp(new Date(paramCursor.getLong(paramCursor.getColumnIndex("msgtime"))));
      localAudioMessage.setiKnowMsgType(i);
      localObject = localAudioMessage;
    }
  }
}